#include <bits/stdc++.h>
using namespace std;
long long t, n, a[25],p[20]={1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768},l[2];
long long r(){
    long long x=0, f=1;
    char c=getchar();
    while(c>'9'||c<'0')if(c=='-')f=-1,c=getchar();else f=1,c=getchar();
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return f*x;
}
int main(){
    freopen("color.in","r", stdin);
    freopen("color.out","w", stdout);
    t=r();
    while(t--){
        n=r();
        int ans=0;
        for(int i = 0; i < n; i++)a[i]=r();
        for(int i = 0; i < p[n]; i++){
            int sum=0;
            l[0]=l[1]=100;
            for(int j = 0; j < n; j++){
                if(a[l[i/p[j]%2]]==a[j])sum+=a[j];
                l[i/p[j]%2]=j;
            }
            ans=max(ans,sum);
        }
        cout<<ans<<endl;
    }
    return 0;
}
